package com.mqy.springmvc.controller.advice;

import com.mqy.springmvc.exception.MyBaseException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author 13159 //作者
 * @version V1.0 //版本
 * @Project 2022.3.8MVCxiaojie
 * @Package com.mqy.springmvc.controller.advice
 * @Description:
 * @Date 2022/3/8 20:37//日期
 * @Motto:放下杂念,只为迎接明天更好的自己
 */

/*增强类捕获异常*/
@ControllerAdvice
@ResponseBody
public class MyControllerAdvice {

    @ExceptionHandler(MyBaseException.class)
    public String processMyBase(MyBaseException e) {
        return e.getMessage();
    }

    @ExceptionHandler(Exception.class)
    public String processMyBase(Exception e) {
        return "dayichang";
    }

}
